define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'user/index' + location.search,
                    add_url: 'user/add',
                    edit_url: 'user/edit',
                    del_url: 'user/del',
                    multi_url: 'user/multi',
                    import_url: 'user/import',
                    table: 'user',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'user_id',
                sortName: 'user_id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'user_id', title: __('User_id')},
                        {field: 'username', title: __('Username'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'tel', title: __('Tel'), operate: 'LIKE'},
                        // {field: 'password', title: __('Password'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'add_time', title: __('Add_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        // {field: 'edit_time', title: __('Edit_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'industry.name', title: __('Industry.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'type.name', title: __('Type.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'position.name', title: __('Position.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'industry_id', title: __('Industry_id')},
                        // {field: 'company_typeid', title: __('Company_typeid')},
                        // {field: 'position_id', title: __('Position_id')},
                        // {field: 'open_id', title: __('Open_id'), operate: 'LIKE'},
                        // {field: 'app_open_id', title: __('App_open_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'wechat_openid', title: __('Wechat_openid'), operate: 'LIKE'},
                        // {field: 'unionid', title: __('Unionid'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'authen', title: __('Authen'), searchList: {"1":__('Authen 1'),"2":__('Authen 2'),"3":__('Authen 3'),"4":__('Authen 4')}, formatter: Table.api.formatter.normal},
                        // {field: 'reason', title: __('Reason'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'add_authen_time', title: __('Add_authen_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'authen_time', title: __('Authen_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'authen_type', title: __('Authen_type'), searchList: {"1":__('Authen_type 1'),"2":__('Authen_type 2')}, formatter: Table.api.formatter.normal},
                        {field: 'end_time', title: __('End_time'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'deposit_price', title: __('Deposit_price'), operate:'BETWEEN',operate: false},
                        {field: 'is_chao_group', title: __('Is_chao_group'), searchList: {"1":__('Is_chao_group 1'),"0":__('Is_chao_group 0')}, formatter: Table.api.formatter.normal},
                        {field: 'is_chao_kf', title: __('Is_chao_kf'), searchList: {"1":__('Is_chao_kf 1'),"0":__('Is_chao_kf 0')}, formatter: Table.api.formatter.normal},

                        // {field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'logo', title: __('Logo'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'province', title: __('Province'), operate: 'LIKE'},
                        // {field: 'city', title: __('City'), operate: 'LIKE'},
                        // {field: 'area', title: __('Area'), operate: 'LIKE'},
                        // {field: 'address', title: __('Address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'zhuying', title: __('Zhuying'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'num', title: __('Num'), operate: 'LIKE'},
                        // {field: 'contact_name', title: __('Contact_name'), operate: 'LIKE'},
                        // {field: 'contact_tel', title: __('Contact_tel'), operate: 'LIKE'},
                        // {field: 'company_image', title: __('Company_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        // {field: 'id_card1_image', title: __('Id_card1_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        // {field: 'id_card2_image', title: __('Id_card2_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        // {field: 'hand_card_image', title: __('Hand_card_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        // {field: 'wx_image', title: __('Wx_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        // {field: 'background_image', title: __('Background_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        // {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'logout', title: __('Logout'), searchList: {"0":__('Logout 0'),"1":__('Logout 1'),"2":__('Logout 2'),"3":__('Logout 3')}, formatter: Table.api.formatter.normal},
                        // {field: 'add_log_time', title: __('Add_log_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        // {field: 'logout_reason', title: __('Logout_reason'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'authen_log_time', title: __('Authen_log_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'is_jin', title: __('Is_jin'), searchList: {"0":__('Is_jin 0'),"1":__('Is_jin 1')}, formatter: Table.api.formatter.normal},
                        // {field: 'logintime', title: __('Logintime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        // {field: 'industry.name', title: __('Industry.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'type.name', title: __('Type.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'position.name', title: __('Position.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            $(document).on("change", "#c-is_chao_kf", function(){
                var is_chao_kf=$("#c-is_chao_kf").val();
                // alert(authen);
                if(is_chao_kf=='1')
                {
                    $("#isxian").show();
                }
                else
                {
                    $("#isxian").hide();
                }

            });
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
